package HRMPROJECT.CONTROLLERS;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.table.DefaultTableModel;

import HRMPROJECT.BASEUTILS.Commons;
import HRMPROJECT.MODELS.SecurityContexts;
import HRMPROJECT.MODELS.TimeKeepingModels;

public class TimeKeepingController {
    private Connection m_objConnection = null;
    private SecurityContexts m_objSecurity = null;
    private TimeKeepingModels m_objModels = null;

    public TimeKeepingController(Connection objConnection, SecurityContexts objSecurity) {
        m_objConnection = objConnection;
        m_objSecurity = objSecurity;

        m_objModels = new TimeKeepingModels(m_objConnection);
    }

    /***
     * Nghiệp vụ hiển thị thông tin chấm công của nhân viên theo Phòng Ban + Tháng năm BC
     * @param DepartId
     * @param DayOf
     * @return
     * @throws SQLException
     */
    public ResultSet getTimeKeepByDepartId(int DepartId, String DayOf) throws SQLException {
        return m_objModels.getElementsById(DepartId, DayOf);
    }

    /***
     * 
     * @param DepartId
     * @param DayOf
     * @return
     * @throws SQLException
     */
    public DefaultTableModel getTimeKeepTableModels(int DepartId, String DayOf) throws SQLException {
        DefaultTableModel objDtm = null;
        try {
            ResultSet objRs = getTimeKeepByDepartId(DepartId, DayOf);
            Commons objComs = new Commons();
            objDtm = new DefaultTableModel();
            objDtm = objComs.getModels(objRs);
        } catch (SQLException e) {
            throw e;
        }
        return objDtm;
    }

}
